package com.bree.erp.jsf.jasper;

import java.util.HashMap;
import java.util.Map;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import com.bree.erp.entity.PurchaseRequisition;
import com.bree.erp.report.jasper.JRPurchaseRequisitionDataSource;
import com.bree.erp.service.PurchaseRequisitionService;

@ManagedBean(name = "purchaseRequisitionReportBean")
@RequestScoped
public class PurchaseRequisitionReport extends AbstractReportBean {
	
	@EJB
	private PurchaseRequisitionService service;
	
	private final String COMPILE_FILE_NAME = "purchaserequisition";
	 
    @Override
    protected String getCompileFileName() {
        return COMPILE_FILE_NAME;
    }
 
    @Override
    protected Map<String, Object> getReportParameters() {
        Map<String, Object> reportParameters = new HashMap<String, Object>();
 
        //reportParameters.put("rtitle", "Hello JasperReports");
 
        return reportParameters;
    }
 
    public String execute(long id) {
        try {
        	        	
        	PurchaseRequisition entity = service.read(id);

        	JRPurchaseRequisitionDataSource ds = new JRPurchaseRequisitionDataSource(entity);
        	
            super.prepareReport(ds);
        } catch (Exception e) {
            // make your own exception handling
            e.printStackTrace();
        }
 
        return null;
    }
}
